Sonic2DController = function(gameObject, runSpeed, jumpSpeed, jumpMovementAccel) {
    SimplePlatformerController.call(this, gameObject, runSpeed);
    this.jumpSpeed = jumpSpeed;
};

Sonic2DController.prototype = Object.create(SimplePlatformerController.prototype);

Sonic2DController.prototype.run = function() {
    if (this.onDebug) {
        this.onDebug();
    }

    var go = this.gameObject;
    var runSpeed = this.runSpeed || this.gameObject.speedX;
    var jumpSpeed = this.jumpSpeed || go.jumpSpeed || go.speedY;
    var jumpMovementAccel = jumpMovementAccel;


    if (go.onGround) {
        if (input.left) {
            this.gameObject.vx = -runSpeed;
            if (this.gameObject.currAnimationName != "walk_l") {
                this.gameObject.animation.gotoAndPlay("walk_l");
                this.gameObject.currAnimationName = "walk_l";
            }
            this.gameObject.facingRight = false;
        } else if (input.right) {
            this.gameObject.vx = runSpeed;
            if (this.gameObject.currAnimationName != "walk_r") {
                this.gameObject.animation.gotoAndPlay("walk_r");
                this.gameObject.currAnimationName = "walk_r";
            }
            this.gameObject.facingRight = true;
        } else {
            this.gameObject.vx = 0;
            if (this.gameObject.facingRight) {
                if (this.gameObject.currAnimationName != "idle_r") {
                    this.gameObject.animation.gotoAndPlay("idle_r");
                    this.gameObject.currAnimationName = "idle_r";
                }
            } else {
                if (this.gameObject.currAnimationName != "idle_l") {
                    this.gameObject.animation.gotoAndPlay("idle_l");
                    this.gameObject.currAnimationName = "idle_l";
                }
            }
        }


        if (input.up) {
            go.move(0, -10);
            this.gameObject.vy = -jumpSpeed;
            if (go.facingRight) {
                if (this.gameObject.currAnimationName != "jump_r") {
                    this.gameObject.animation.gotoAndPlay("jump_r");
                    this.gameObject.currAnimationName = "jump_r";
                }
            } else {
                if (this.gameObject.currAnimationName != "jump_l") {
                    this.gameObject.animation.gotoAndPlay("jump_l");
                    this.gameObject.currAnimationName = "jump_l";
                }
            }
        }

    } else {
        if (input.left) {
            if (jumpMovementAccel) {
                this.gameObject.vx += -jumpMovementAccel;
            } else {
                this.gameObject.vx = -runSpeed;
            }
            if (this.gameObject.currAnimationName != "jump_l") {
                this.gameObject.animation.gotoAndPlay("jump_l");
                this.gameObject.currAnimationName = "jump_l";
            }
            this.gameObject.facingRight = false;
        } else if (input.right) {
            if (jumpMovementAccel) {
                this.gameObject.vx += jumpMovementAccel;
            } else {
                this.gameObject.vx = runSpeed;
            }
            if (this.gameObject.currAnimationName != "jump_r") {
                this.gameObject.animation.gotoAndPlay("jump_r");
                this.gameObject.currAnimationName = "jump_r";
            }
            this.gameObject.facingRight = true;
        } else {
            this.gameObject.vx = 0;
            if (this.gameObject.facingRight) {
                if (this.gameObject.currAnimationName != "jump_r") {
                    this.gameObject.animation.gotoAndPlay("jump_r");
                    this.gameObject.currAnimationName = "jump_r";
                }
            } else {
                if (this.gameObject.currAnimationName != "jump_l") {
                    this.gameObject.animation.gotoAndPlay("jump_l");
                    this.gameObject.currAnimationName = "jump_l";
                }
            }
        }
    }





}; //run
